@layout("/common/_container.html"){
<script type="text/javascript">
	var ctx="${ctxPath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
		initMenuBtn("btns","${code}");
	});
	
	function initGrid(){
		var grid_url = ctx+"/${code}/list/";//查询列表接口
		var _colnames=[ "序列","模块名称", "物理路径", "包名","实体名","表名","主键名"];
		var _colmodel=[   {name:"id",index:"id", width:80,hidden:true},
						  {name:"name",index:"name", width:120},
						  {name:"realpath",index:"realpath", width:200},
						  {name:"packagename",index:"packagename", width:150},
						  {name:"modelname",index:"modelname", width:60},
						  {name:"tablename",index:"tablename", width:50},
						  {name:"pkname",index:"pkname", width:50}
						];
		
		jQuery(grid_selector).jqGrid({
			url:grid_url,
		    shrinkToFit:true,//适用于较少字段,响应式
			colNames:_colnames,
			colModel:_colmodel, 
			jsonReader:{id:"id"},
			pager : pager_selector,
			postData: {sort: "id", order: "desc"}
		});
		

	}
	
	
	function btnCallBack(btn){
		if (btn.id == "generate_gencode") {
			var ids = getGridXls().join(",");
	        var rows = getGridXls().length;
	        if (rows == 0) {
                layer_alert("请选择一条数据!", "warn");
                return;
            }
            layer.confirm("是否确定生成代码？", {
                icon: 3,
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post("${ctxPath}/${code}/code", { ids: ids }, function (data) {
                    if (data.code === 0) {
                        layer_alert(data.message, "success");
                    } else {
                    	layer_post(data);
                    }
                }, "json");

            }, function () {
                //layer.msg('已取消');
            });
            return;
		}
	}
	
</script>


	<!-- 配置grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!-- 配置查询 -->
			@ var _col=[
			@			  {name:"包名",index:"packagename", type:"text"},
			@		      {name:"实体名",index:"modelname",type:"text"},
			@			  {name:"表名",index:"tablename", type:"text"}
			@		   ];
			@ include("/common/_function/_search.html",{"col":_col}){}
			<!-- 按钮组 -->
			<div class="welljq well-sm" id="btns"></div>
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页 -->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入列表页所需js -->
	@include("/common/_listscript.html", {isExport : false}) {}
@}	